<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        .active{
            color: red;
            display: block;
        }
        .test{
            display: none;
        }
    </style>
</head>
<body>
<div class="test1">1</div>
<div class="test2">2</div>
<script src="lib/jquery-3.0.0.min.js"></script>
<script>

    var n = 1;
    function changePage() {

        var len = $('.test').length;
        n=n>len?1:n;
        for (var i=0;i<(len+1);i++){
            if(i == n){
                $('test'+i).addClass('active');
            }else {

            }
        }
    }
</script>
</body>
</html>